package com.atguigu.netty.http;

import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

/**
 * @Auther: qwj
 * @Date: 2019/12/25 11:24
 * @Description:
 */
public class ServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel ch) throws Exception {

        //向管道加入处理器

        //得到管道
        ChannelPipeline pipeline = ch.pipeline();
        //加入一个netty HttpServerCodec http编解码器
        pipeline.addLast("myHttpServerCodec",new HttpServerCodec());
        //增加一个自定义的handler
        pipeline.addLast("myHttpServerHandler",new HttpServerHandler());

    }
}
